package chapter3.lessons.characterStreamPart;

import java.io.FileReader;
import java.io.IOException;

/**
 * @Project ：learn_java
 * @File ：ReaderDemo01.java
 * @IDE ：IntelliJ IDEA
 * @Author ：自由如风间
 * @Date ：2025/3/1 10:33
 * @Description ：For study.
 */

public class ReaderDemo01 {
    public static void main(String[] args) throws IOException {
        FileReader fr = new FileReader("G:/codes/learn_java/IOTestOutputFiles/test.txt");
        /*
        // 一次读取一个字符
        int len = 0;
        while ((len = fr.read()) != -1) {
            System.out.print((char) len);
        }
        */

        // 一次读取多个字符
        char[] chars = new char[1024];
        int len = 0;
        while ((len = fr.read(chars)) != -1) {
            System.out.print(new String(chars, 0, len));
        }
        fr.close();
    }
}
